package top.healthylife.mapper;/*
 *@Author GaoZeXi
 *@Created time 2020/4/18 7:23
 *@Description:
 * Step by Step  and Stand on,  You Are The Best Investment!!!
 */


import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import top.healthylife.domain.CheckItem;
import top.healthylife.domain.Role;

import java.util.Map;
import java.util.Set;

/**
 * @author GaoZeXi
 */
public interface RoleMapper  {
    
    Page<Role> selectByCondition(@Param("value") String queryString);

    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    @Insert("insert into t_role value (null,#{name},#{keyword},#{description})")
    void add(Role role);

    @Insert("insert into t_role_permission values (#{role_id},#{permission_id})")
    void setRoleAndPermission(Map<String, Integer> map);

    @Delete("delete from t_role where id=#{id}")
    void deleteById(Integer id);

    /**
     * 根据用户id查询对应角色 以及关联的菜单信息
     * @param userId
     * @return
     */

    Set<Role> findByUserId(Integer userId);

    /**
     * 根据id查询角色信息
     * @param roleId
     * @return
     */
    @Select("select * from t_role where id=#{roleId}")
    Role findById(Integer roleId);
}
